// 凑硬币
function coinChange(coins, amount) {
    function dp(n) {
        // base case
        if (n === 0) return 0
        if (n < 0) return -1
        let res = Infinity
        for(const coin of coins) {
            let subRes = dp(n - coin)
            // 子问题无解, 跳过
            if (subRes === -1) continue
            res = Math.min(res, 1 + subRes)
        }

        if (res !== Infinity) return res
        else return -1
    }
    return dp(amount)
}
//







